$(function() {
	$("#insert").click(function() {
		insert();
	});

})


function insert() {
	// var customerCode = $("#customerCode").val();
	var customer = $("#customer").val();
	var phone = $("#phone").val();
	var fax = $("#fax").val();
	var address = $("#address").val();
	var postCode = $("#postCode").val();
	var linkman = $("#linkman").val();
	var linkmanMobile = $("#linkmanMobile").val();
	var customerType = $("#customerType").val();
	var enterpriseProperty = $("#enterpriseProperty").val();
	var enterpriseSize = $("#enterpriseSize").val();
	var email = $("#email").val();
	// if (customerCode == null || customerCode == "") {
	// 	alert("客户编号不可为空");
	// 	return false;
	// }
	if (customer == null || customer == "") {
		alert("客户名称不可为空");
		return false;
	}
	if (phone == null || phone == "") {
		alert("电话不可为空");
		return false;
	}
	// if (fax == null || fax == "") {
	// 	alert("传真不可为空");
	// 	return false;
	// }
	if (address == null || address == "") {
		alert("地址不可为空");
		return false;
	}
	if (postCode == null || postCode == "") {
		alert("邮编不可为空");
		return false;
	}
	if (linkman == null || linkman == "") {
		alert("联系人不可为空");
		return false;
	}
	if (linkmanMobile == null || linkmanMobile == "") {
		alert("联系人手机不可为空");
		return false;
	}
	if (customerType == null || customerType == "") {
		alert("客户类型不可为空");
		return false;
	}
	if (enterpriseProperty == null || enterpriseProperty == "") {
		alert("企业性质不可为空");
		return false;
	}
	if (enterpriseSize == null || enterpriseSize == "") {
		alert("企业规模不可为空");
		return false;
	}
	if (email == null || email == "") {
		alert("电子邮件不可为空");
		return false;
	}

	$.ajax({
		url: 'http://localhost:9000/customer/customerinformation/fillin',
		type: 'get',
		dataType: 'json',
		data: {
			// "customerCode": customerCode,
			"customer": customer,
			"phone": phone,
			"fax": fax,
			"address": address,
			"postCode": postCode,
			"linKman": linkman,
			"linkmanMobile": linkmanMobile,
			"customerType": customerType,
			"enterpriseProperty": enterpriseProperty,
			"enterpriseSize": enterpriseSize,
			"email": email
		},
		success: function(map) {
			var msg = map.msg;
			if (msg.indexOf("成功") != -1) {
				alert(msg);
				window.location.href = 'customer.html';
			} else {
				alert(msg + ",请重试");
			}
		}
	})
}



/* customerCode
customer
phone
fax
address
postCode
linkman
linkmanMobile
customerType
enterpriseProperty
enterpriseSize
email */
